<?php
namespace Stock\Controller;
use Stock\Logic;
use Think\Controller;

/**
 * Created by PhpStorm.
 * User: wangli
 * Date: 15-5-6
 * Time: 下午4:28
 */


class StockController extends Controller{

    function __construct(){
        parent::__construct();

        //$this->trade_logic = new Logic\TradeLogic();
       // $this->hold_logic = new Logic\HoldLogic();


    }


    //mytv中的应用推荐
    public  function  dzjy(){
        $hash = $_GET['hash'];
        $channel = $_GET['c'];
        $version = $_GET['v'];


        $params['order']= $_GET['order'];
        if(!isset($_GET['date'])){
            $params['date'] = time()-3600*24*365;
        }else{
            $params['date'] = $_GET['date'];
        }



        $key = __CLASS__.__FUNCTION__.$channel.$version;
       // $this->mem = new Lib_Mem($this->mem_app);
      //  $data = $this->mem->get($key);
        $debug  =   isset($_GET['debug']) ? $_GET['debug'] : '0';
        if(!$data || $debug == 1){
            $trade_logic =new Logic\TradeLogic();;
            $data = $trade_logic->getTrade($params);
           // $this->mem->set($key,$data);
        }

        $new_hash = substr(md5(json_encode($data)),8,16);
        if($hash == $new_hash){
            $res['status']=1;
        }else{
            $res['status']=0;
            $res['hash']=$new_hash;
            $res['data']= $data;
        }
        echo json_encode($res);
    }





    public  function hello(){
        echo 'list';
    }












}